h1 #{t('hello')}, #{current_user.email}!

h2 = t('key_management')

.info
  - if current_user.public_key.present?
    h3 = t('your_public_key')
    pre.mb-4 = current_user.public_key

div data-controller="keys"
  .form
    .field
      label for="full_name" Full name
      br
      input id="full_name" type="text" data-keys-target="username"

    .field
      label for="passphrase" Passphrase
      br
      input id="passphrase" type="password" data-keys-target="passphrase"

  = form_with model: current_user do |f|
    = f.hidden_field :email, name: nil, value: current_user.email, data: { keys_target: "email" }

    .button
      button data-action="click->keys#generate" Generate Key Pair

    .field
      = f.label :public_key
      br
      = f.text_area :public_key, required: true, data: { keys_target: "publicKey", action: "input->keys#publicKeyInput" }

    .field
      = f.label :private_key
      br
      = f.text_area :private_key, name: nil, data: { keys_target: "privateKey", action: "input->keys#privateKeyInput" }

    .field
      = f.label :fingerprint
      br
      = f.text_field :fingerprint, data: { keys_target: "fingerprint" }, readonly: true

    .button
      = f.submit "Update Keys", data: { action: "click->keys#register" }
